<template>
  <div class="detail">
    <!-- 头部组件 -->
    <HmHeader :showArrow="true" @clickLeft="fn">
      面经详情
      <template #rigth>🔍</template>
    </HmHeader>

    <!-- <van-button type="primary" size="mini" color="red">登录</van-button>
    <van-button type="info" size="mini" color="green" @click="fn2"
      >惦记了</van-button
    > -->
    <h1>{{ obj.stem }}</h1>
    <div class="info">
      <span>{{ obj.createdAt }}</span>
      <span>|</span>
      <span>{{ obj.views }}浏览量</span>
      <span>|</span>
      <span>{{ obj.likeCount }} 点赞数</span>
    </div>

    <div class="qian">
      <img :src="obj.avatar" />
      <span>{{ obj.creator }}</span>
    </div>

    <div class="content">
      {{ obj.content }}
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  created() {
    console.log(this.$route.query.id);
    this.getDetail(this.$route.query.id);
    // console.log(this.obj);
  },
  data() {
    return {
      obj: {},
    };
  },
  methods: {
    async getDetail(id) {
      const token = localStorage.getItem("token");
      // console.log("我是token", token);
      const res = await axios({
        url: "http://interview-api-t.itheima.net/h5/interview/show",
        params: {
          id,
        },
        headers: {
          Authorization: `Bearer ${token}`,
        },
      });
      this.obj = res.data.data;
      // console.log(res);
    },
    fn() {
      this.$router.back();
    },
    fn2() {
      alert("哈哈");
    },
  },

  // data() {
  //   return {};
  // },
  name: "HmDetail",
};
</script>
<style lang="less" scoped>
.qian {
  display: flex;
  align-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}

.content {
  text-indent: 2em;
}
</style>
